package com.yiduan.apollocrm.views.mediators
{
	
	import com.pialabs.eskimo.events.ConfirmEvent;
	import com.yiduan.apollocrm.services.LeadService;
	import com.yiduan.apollocrm.views.*;
	
	import org.robotlegs.mvcs.Mediator;
	
	import spark.events.IndexChangeEvent;
	
	public class HomeMediator extends Mediator
	{
		[Inject]
		public var homeView:HomeView;
		
		public function HomeMediator() {
			super();
		}
		
		override public function onRegister():void {
			homeView.categoryList.addEventListener(IndexChangeEvent.CHANGE, onCategoryListChange);
		}
		
		protected function onCategoryListChange(event:IndexChangeEvent):void
		{
			var selectedItemName:String = homeView.categoryList.selectedItem.name;
			if (selectedItemName == "LEADS") {
				homeView.navigator.pushView(LeadsView);
			} else if (selectedItemName == "PRODUCTS") {
				homeView.navigator.pushView(ProductsView);
			} else if (selectedItemName == "OPPORTUNITIES") {
				homeView.navigator.pushView(OpportunitiesView);
			} else if (selectedItemName == "CONTRACTS") {
				homeView.navigator.pushView(ContractsView);
			} else if (selectedItemName == "DASHBOARDS") {
				homeView.navigator.pushView(DashboardView);
			} else if (selectedItemName == "CAMPAIGNS"){
				homeView.navigator.pushView(CampaignView);
			}
		}

	}
}